#!c:\python32\python.exe -u
# -*- encoding: gb2312 -*- 
import sys
import os
from stat import *
import urllib.request, urllib.parse, urllib.error
import re
import shutil
import time
import getopt

def Occident():
    url = r'http://list.mp3.baidu.com/top/oumeigeshou.html'
    f = urllib.request.urlopen(url)
    html = f.read()
    f.close();
    m = r'<td><span>\d+.</span><a href="http://mp3.baidu.com/singerlist/.*.html" target="_blank" >.*</a></td>'
    s = str(html, 'gb2312', 'ignore')
    words = []
    for r in re.findall(m,s,re.MULTILINE):
        words.append(re.compile(r'.*>([^<>]*)</a></td>$').search(r).groups()[0])
    return words

def BuildKeywords(input=""):
    if input == "occident" or input == "":
        return Occident()
    else:
        return [input]

if "__main__" == __name__:
    print (sys.argv)
    if len(sys.argv) == 2:
        print (BuildKeywords(sys.argv[1]))
    else:
        print (BuildKeywords())
